/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package encaps.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; 
import java.io.UnsupportedEncodingException; 

/**
 *
 * @author fon_Valter
 */
public class MD5Hash 
{
    public MD5Hash()
    {
    }
    public static String getHash(String str) throws NoSuchAlgorithmException,
         UnsupportedEncodingException 
      {
      MessageDigest m = MessageDigest.getInstance("MD5");
      m.reset();
      m.update(str.getBytes("utf-8"));
      String s2 = new BigInteger(1, m.digest()).toString(16);
      StringBuilder sb = new StringBuilder(32);
      for (int i = 0, count = 32 - s2.length(); i < count; i++) {
         sb.append("0");
      }
      return sb.append(s2).toString();
   }  
}
